﻿CREATE TABLE [dbo].[t_Address] (
    [ID]              INT            IDENTITY (1, 1) NOT NULL,
    [BorrowerID]      INT            NOT NULL,
    [Pos]             TINYINT        NOT NULL,
    [Street]          VARCHAR (50)   NOT NULL,
    [CityName]        VARCHAR (50)   NOT NULL,
    [Zip]             [dbo].[DT_Zip] NOT NULL,
    [Zip0]            AS             (case isnumeric([zip]) when (1) then CONVERT([int],[zip],(0))  end) PERSISTED,
    [StateCode]       CHAR (2)       NOT NULL,
    [Years]           INT            NOT NULL,
    [Months]          INT            NOT NULL,
    [LandLord]        VARCHAR (50)   NULL,
    [LandLordPhone]   VARCHAR (12)   NULL,
    [TimeLength]      AS             (isnull([Years],(0))*(12)+isnull([Months],(0))) PERSISTED,
    [AddressTypeID]   TINYINT        NOT NULL,
    [Phone]           VARCHAR (50)   NULL,
    [HouseHoldTypeID] INT            NOT NULL,
    [HousePayment]    SMALLINT       NULL
);

